/*
 * @Description:
 * @Version: 1.0
 * @Autor: gaoluo
 * @Date: 2022-05-05 17:46:13
 * @LastEditors: gaoluo
 * @LastEditTime: 2022-05-23 15:24:10
 * @FilePath: /vue3.0-vite-ts-xiaotuxian/src/api/index.ts
 */
import axios from "axios";
import { useStore } from "@/stores";
const baseURL = "http://127.0.0.1:4523/mock/928108";
const request = axios.create({
  baseURL,
  timeout: 10000,
});
const store = useStore();
request.interceptors.request.use(
  (config) => {
    return config;
  },
  (err) => {
    return Promise.reject(err);
  }
);

request.interceptors.response.use((config) => {
  if (config.data.code === 200) {
    return config.data;
  } else {
    console.log("请求失败！");
  }
});

export default request;
